<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - AI简历分析系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        /* 统一的CSS变量 */
        :root {
            --primary-color: #5A67D8;
            --primary-hover: #434B9A;
            --text-color: #2D3748;
            --light-gray: #F7FAFC;
            --border-color: #E2E8F0;
            --error-color: #E53E3E;
        }

        body {
            font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
            background-color: var(--light-gray);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            color: var(--text-color);
        }

        .container {
            background-color: white;
            padding: 3rem;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
            width: 100%;
            max-width: 450px; /* 略微放宽以容纳更多内容 */
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .container:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
        }

        h2 {
            margin: 0 0 2rem 0;
            color: var(--text-color);
            font-weight: 600;
            text-align: center;
        }

        .form-group {
            margin-bottom: 2rem;
        }

        .form-control {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 0.75rem 1rem;
            width: 100%;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            outline: none;
            box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
        }

        button {
            width: 100%;
            padding: 0.75rem;
            border: none;
            border-radius: 8px;
            background-color: var(--primary-color);
            color: white;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: background-color 0.3s ease, transform 0.2s ease;
        }

        button:hover {
            background-color: var(--primary-hover);
            transform: translateY(-2px);
        }

        .link-container {
            margin-top: 1.5rem;
            text-align: center;
        }

        .link {
            color: var(--primary-color);
            text-decoration: none;
            font-size: 0.9rem;
            transition: color 0.3s ease;
        }

        .link:hover {
            color: var(--primary-hover);
            text-decoration: underline;
        }

        .error-message {
            color: var(--error-color);
            margin-bottom: 1.5rem;
            text-align: center;
        }

    </style>
</head>
<body>
<div class="container">
    <h2 class="text-center">用户注册</h2>

    <div th:if="${error}" class="alert alert-danger error-message">
        <p th:text="${error}"></p>
    </div>

    <form th:action="@{/register}" method="post">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" class="form-control" id="username" name="username"
                   placeholder="请输入用户名（4-20个字符）" required>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password" name="password"
                   placeholder="请输入密码（至少6位）" required>
        </div>

        <div class="form-group">
            <label for="confirmPassword">确认密码</label>
            <input type="password" class="form-control" id="confirmPassword" name="confirmPassword"
                   placeholder="请再次输入密码" required>
        </div>

        <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
        <button type="submit">注册</button>
    </form>

    <div class="link-container">
        <a class="link" th:href="@{/login}">已有账号？立即登录</a>
    </div>

</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>